package cn.itcast.wushangxiantu.BaseAdapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import cn.itcast.wushangxiantu.Fragment.home.NongTian;
import cn.itcast.wushangxiantu.R;

public class NongYuanAdapter extends BaseAdapter {
    private Context context;
    private LayoutInflater layoutInflater;

    public NongYuanAdapter(Context context) {
        layoutInflater = LayoutInflater.from(context);
        this.context = context;
    }

    @Override
    public int getCount() {
        return NongTian.getLists().size();
    }

    @Override
    public Object getItem(int i) {
        return NongTian.getLists().get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @SuppressLint("ResourceAsColor")
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = layoutInflater.inflate(R.layout.listview_nongyuan, null);
        ViewHolder viewHolder = new ViewHolder(view);
        String content="";
        content+="【" + NongTian.getLists().get(i).getDiquName() + "】获得：";
        if (NongTian.getLists().get(i).getPingzhi().equals("1")) {
            content+="【" + NongTian.getLists().get(i).getName() + "】";
        } else {
            content+=NongTian.getLists().get(i).getName();
        }
        content+="*" + NongTian.getLists().get(i).getNumber();
        viewHolder.tvWp.setText(content);
        return view;
    }

    class ViewHolder {
        public View rootView;
        public TextView tvWp;

        public ViewHolder(View rootView) {
            this.rootView = rootView;
            this.tvWp = (TextView) rootView.findViewById(R.id.tvWp);
        }

    }
}
